﻿using System;
using System.IO;

namespace 使用文件流对文件进行复制
{
	class Program
	{
		static void Main(string[] args)
		{

			string s1 = @"E:\虚妄之屋\BGM包（可自由商用）（魔王魂）.rar";  //源文件地址
			string s2 = @"E:\壁纸\复制的文件.rar";					   //被复制的文件地址
			CopyFile(s1, s2);
			Console.WriteLine("复制OK");
			Console.ReadKey();
		}
		public static void CopyFile(string soure,string target)
		{
			using(FileStream fsRead=new FileStream(soure, FileMode.OpenOrCreate, FileAccess.Read))
			{
				using(FileStream fsWrite = new FileStream(target, FileMode.OpenOrCreate, FileAccess.Write))
				{
					byte[] buffer = new byte[1024 * 1024 * 5];
					while (true)
					{
						int r = fsRead.Read(buffer, 0, buffer.Length);
						if (r == 0)
							break;
						fsWrite.Write(buffer, 0, r);
					}
				}
			}
		}
	}
}
